<?php

namespace Largezhou\Admin\Traits;

trait TreeSelectOptions
{
    use TreeOptions;

    /**
     * 生成elementui中cascader所需的数据格式
     *
     * @param null $items
     * @param int  $parentId
     *
     * @return array
     */
    public static function makeTreeSelectOptions($items = null, $parentId = 0)
    {
        return static::makeTreeOptions($items, $parentId, function ($item) {
            return [
                'value' => $item['id'],
                'label' => $item[static::titleColumn()],
            ];
        });
    }
}
